package concurrencyCookBook;

public class Demo {

	public static void main(String[] args) {
		BC b=new BC();
		AC a=new AC(b);
		Thread thread=new Thread(a);
		thread.start();
		System.out.println("main");
		b.to();
	}

}

class AC implements Runnable {
	private BC b;

	public AC(BC b) {
		super();
		this.b = b;
	}

	@Override
	public void run() {
		b.go();
	}

}

class BC {
	private Integer i;

	public synchronized void go() {
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("go");
	}

	public synchronized void to() {
		System.out.println("to");
	}

	public Integer getI() {
		return i;
	}

	public void setI(Integer i) {
		this.i = i;
	}
}
